package sort

//冒泡排序
func Bsort(a []int) {
	for i := 0; i < len(a); i++ {
		for j := 0; j < len(a)-i-1; j++ {
			if a[j] > a[j+1] {
				a[j], a[j+1] = a[j+1], a[j]
			}
		}
	}
}

//选择排序
func Ssort(a []int) {
	for i := 1; i < len(a); i++ {
		for j := i; j > 0; j-- {
			if a[j] > a[j-1] {
				break
			}
			a[j], a[j-1] = a[j-1], a[j]
		}
	}
}

//快速排序
func Ksort(a []int, left int, right int) {

	if left == right {
		return
	}
	for i := 0; i < right-left; i++ {
		if a[i] > a[i+1] {
			a[i+1], a[i] = a[i], a[i+1]
		}
	}
	left++
	Ksort(a, left, right)
}
